<template>
  <view>
      <view class="comment" :style="isMyself === res.parentCreater ? 'background-color:#EEECFC;': ''" v-for="(res,index) in commentsList" :key="index">
      
			<view class="left">
        <item-image :img="res.avatar" :width="100" :height="100" :radius="50" />
      </view>
			<view class="right">
				<view class="top">
					<view class="name">{{ res.createrName }}</view>
					<view class="like">
						<!-- <view class="num">{{ res.likeNum }}</view> -->
						<!-- <u-icon v-if="!res.isLike" name="thumb-up" :size="30" color="#9a9a9a" @click="getLike(index)"></u-icon>
						<u-icon v-if="res.isLike" name="thumb-up-fill" :size="30" @click="getLike(index)"></u-icon> -->
            <view v-if="isMyself !== res.creater" @click="reply(res.creater,res.createrName)" class="">回复</view>
            <view v-if="isMyself === res.creater" @click="deleteComments(res)">删除</view>
					</view>
				</view>
        	<view class="date">
					{{ res.createTime | createTimeFilte }}
				</view>
				<view class="content" v-if="!res.parentCreater">{{ res.content }}</view>
        
				<view class="content" v-if="res.parentCreater"><text style="margin-right:8rpx">回复&nbsp;</text> <text> {{res.parentCreaterName}}</text>：{{ res.content }}</view>
				<!-- <view class="content" v-if="res.parentCreater">{{ res.content }}</view> -->

        <view class="right-border-bottom"></view>
			</view>
      
		</view>
  </view>
</template>

<script>
import { mapGetters } from 'vuex'
import dayjs from 'dayjs';
export default {
  name: 'comments',
  props: {
     commentsList: {
       type: Array
     },
  },
  data () {
    return {
      show:false,
      focus: false,
    }
  },
  created () {
    
  },
  computed: {
    ...mapGetters(['loginForm']),
    isMyself(){
      return this.loginForm.uid
    }
  },
  
  methods: {
    // 回复
    reply(creater,createName){
      this.focus = !this.focus
      this.$emit("onFocus", { focus:this.focus, creater,createName:`回复${createName}：`})
    },
    // 删除评论
    deleteComments(data){
      uni.showModal({
				content: '确认删除?',
				confirmText:'确认',
        cancelText:'取消',
				title:'温馨提示',
				success:({confirm,cancel}) => {
          if(confirm) {
            console.log('确认');
             this.$emit('delete',data)
          } 
          if(cancel) {
            console.log('取消');
          }
        }
			})
     
    }
    // 查看所有评论
    // toAllReply(){
    //   this.show = true
    //   console.log(123,'你好啊');
    // },
    // 评论列表
  }
}
</script>

<style lang="scss" scoped>
  .comment {
	display: flex;
	padding: 28rpx;
  
	.left {
		image {
			width: 100rpx;
			height: 100rpx;
			border-radius: 50%;
			background-color: #f2f2f2;
		}
	}
	.right {
		flex: 1;
		padding-left: 20rpx;
		font-size: 30rpx;
    .right-border-bottom{
      width: 100%;
      height: 1rpx;
      border-bottom: 1rpx #f0f1f5 solid;
      position: relative;
      top: 30rpx;
    }
		.top {
			display: flex;
			justify-content: space-between;
			align-items: center;
			margin-bottom: 10rpx;
			.name {
				color: #333333;
        font-size: 30rpx;
			}
			.like {
				display: flex;
				align-items: center;
        margin-right: 10rpx;
				color: #4D4D4D;
				font-size: 26rpx;
        padding: 6rpx;
        border-radius: 6rpx;
        background-color: #F0F1F5;
			}
		}
		.content {
      font-size: 24rpx;
			margin-bottom: 10rpx;
		}
		.reply-box {
			background-color:#F0F1F5;
			border-radius: 12rpx;
      font-size: 24rpx;
      color: #4D4D4D;
			.item {
				padding: 12rpx;
        padding-bottom: 0;
				// border-bottom: solid 2rpx $u-border-color;
				.username {
					font-size: 30rpx;
					color: #333333;
				}
			}
			.all-reply {
				padding: 20rpx;
				display: flex;
				color: #765CFE;
				align-items: center;
        font-size: 30rpx;
				.more {
					margin-left: 6rpx;
				}
			}
		}
		// .bottom {
		// 	margin-top: 20rpx;
		// 	display: flex;
		// 	font-size: 24rpx;
		// 	color: #9a9a9a;
		// 	.reply {
		// 		color: #5677fc;
		// 		margin-left: 10rpx;
		// 	}
		// }
	}
}

.date {
  margin-bottom: 10rpx;
  font-size: 24rpx;
  color: #4D4D4D;
}

.popup-parcel {
  padding-bottom: 150rpx;
}

.comments-header {
  border-bottom: 1rpx #f0f1f5 solid;
  padding: 30rpx 30rpx 0 30rpx
}

.comments-detail {
  padding: 30rpx 0;
}

.user-comtent {
  display: flex;
}

.user-avactar {
  align-items: flex-start;
  margin-right: 20rpx;
}

.user-content-info {
  display: flex;
  flex-direction: column;
}

.huifu {
  color: #000;
  font-size: 28rpx;
  margin: 20rpx 0 30rpx 30rpx;
}

.comments-items {
  padding: 0 30rpx 0rpx 30rpx;
}
</style>
